<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sp" uri="http://www.springframework.org/tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>My JSP 'add.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
<meta http-equiv="description" content="This is my page" />
<link href="/css/reset.css" rel="stylesheet" type="text/css" />
<link href="/css/common.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="/js/jquery_datapicker/themes/min/jquery.ui.all.min.css" />
<link rel="stylesheet" href="/js/jquery_datapicker/themes/min/jquery.ui.datepicker.min.css" />
<script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="/js/jquery_datapicker/ui/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="/js/jquery_datapicker/ui/jquery.ui.widget.min.js"></script>
<script type="text/javascript" src="/js/jquery_datapicker/ui/jquery.ui.datepicker.min.js"></script>
<script type="text/javascript" src="/js/jquery_datapicker/ui/i18n/jquery.ui.datepicker-zh-CN.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/js/formcheck/formcheck-0.0.1.js"></script>
<style type="text/css">
#tr_upload td {
	display: none;
	visibility: hidden;
}
</style>
</head>

<body class="mainframe">
  <form action="/admin/advertise/add.dhtml" method="post">
    <input type="hidden" name="advertise.catalogId" value="<c:out value="${advertise.catalogId}" />" />
    <table class="admin_table">
      <caption>添加广告</caption>
      <c:choose>
        <c:when test="${message.info != null }">
          <tr>
            <td colspan="2"><sp:message code="${message.info}" text="" /></td>
          </tr>
        </c:when>
        <c:otherwise>
          <tr>
            <td>标题</td>
            <td><input type="text" id="advertiseName" name="advertise.name" /><span id="advertiseNameTip"></span></td>
          </tr>
          <tr>
            <td>描述</td>
            <td><textarea id="advertiseNote" name="advertise.note" rows="4" cols="100"></textarea></td>
          </tr>
          <tr>
            <td>广告类型</td>
            <td><select id="advertiseType" name="advertise.type">
                <option value="2">文字</option>
                <option value="0">图片</option>
                <option value="1">flash</option>
            </select></td>
          </tr>
          <tr>
            <td>资源路径</td>
            <td><input type="text" id="uploadImg" name="advertise.path" /></td>
          </tr>
          <tr>
            <td>宽度</td>
            <td><input type="text" id="advertiseWidth" name="advertise.width" /></td>
          </tr>
          <tr>
            <td>高度</td>
            <td><input type="text" id="advertiseHeight" name="advertise.height" /></td>
          </tr>
          <tr>
            <td>链接</td>
            <td><input type="text" id="advertiseUrl" name="advertise.url" /></td>
          </tr>
          <tr>
            <td>是否新窗口打开</td>
            <td><select id="advertiseNewWindow" name="advertise.newWindow">
                <option value="0">否</option>
                <option value="1">是</option>
            </select></td>
          </tr>
          <tr>
            <td>开始时间</td>
            <td><input type="text" id="advertiseBegintime" name="advertise.begintime" /></td>
          </tr>
          <tr>
            <td>结束时间</td>
            <td><input type="text" id="advertiseEndtime" name="advertise.endtime" /></td>
          </tr>
          <tr>
            <td>是否启用</td>
            <td><select id="advertiseState" name="advertise.state">
                <option value="0">否</option>
                <option value="1">是</option>
            </select></td>
          </tr>
          <tr id="tr_upload">
            <td valign="top">上传资源</td>
            <td><iframe id="frame_upload" name="frame_upload" class="upload" width="400" height="200"
                src="/common/upload.dhtml?savePath=advertise/" scrolling="no" frameborder="0"></iframe></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><input type="submit" class="button01" value="添加" /></td>
          </tr>
        </c:otherwise>
      </c:choose>
    </table>
  </form>
  <script type="text/javascript">
			// 日期范围选择
			var dates = $("#advertiseBegintime, #advertiseEndtime")
					.datepicker(
							{
								defaultDate : "+1w",
								changeMonth : true,
								numberOfMonths : 3,
								onSelect : function(selectedDate) {
									var option = this.id == "advertiseBegintime" ? "minDate"
											: "maxDate", instance = $(this)
											.data("datepicker"), date = $.datepicker
											.parseDate(
													instance.settings.dateFormat
															|| $.datepicker._defaults.dateFormat,
													selectedDate,
													instance.settings);
									dates.not(this).datepicker("option",
											option, date);
								}
							});

			// 广告类型选择

			$("#advertiseType").change(function() {
				//alert($(this).val());
				if ($(this).val() == "" || $(this).val() == 2) {
					$("#tr_upload td").css({
						"display" : "none",
						"visibility" : "hidden"
					});
				} else {
					$("#tr_upload td").css({
						"display" : "table-cell",
						"visibility" : "visible"
					});
				}
			});
			// 表单验证
			var formCheck = $.formCheck();
			formCheck.regAllEmpty("advertiseName", {
				onShow : "输入目录名称",
				onFocus : "此项为必填",
				onError : "此项为必填",
				onCorrect : "目录名称输入正确"
			}, true);
			formCheck.formCheck("advertiseCateForm");
		</script>
</body>
</html>